package com.Dubbo.RWSeparate.provider.write.service.demo;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.Dubbo.RWSeparate.api.demo.entity.Demo;
import com.Dubbo.RWSeparate.api.demo.service.write.IDemoWriteService;
import com.Dubbo.RWSeparate.provider.write.dao.demo.DemoMapper;

@Service(value = "demoService")
public class DemoWriteServiceImpl implements IDemoWriteService{

	@Resource(name = "demoMapper")
	private DemoMapper demoMapper;
	
	/**
	 * 此方法返回主键id
	 * 如果insert操作更新的行数  >0 的话，返回主键id; 如果更新的行数不大于0的话，返回0；
	 */
	@Override
	public int insertEntity(Demo demo) {
		int insertEntityReturnId = demoMapper.insertEntity(demo);
		if(insertEntityReturnId > 0) {
			return demo.getId();
		} else {
			return 0;
		}
	}

}
